package cjakma.study.portfolio.common.validation.constraints;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import cjakma.study.portfolio.common.validation.constraints.impl.CodeIntValueValidator;

/**
 * 정수형 코드의 validation 처리를 위한 어노테이션.
 * @author 서성수
 */
@Documented
@Constraint(validatedBy = { CodeIntValueValidator.class })
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
public @interface CodeIntValue {
	String message() default "{cjakma.study.portfolio.common.validation.constraints.CodeIntValue.message}";

	Class<?>[] groups() default {};

	Class<? extends Payload>[] payload() default {};

	int[] value();

	/**
	 * Defines several {@code @CodeValue} annotations on the same element.
	 */
	@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
	@Retention(RUNTIME)
	@Documented
	public @interface List {
		CodeIntValue[] value();
	}
}
